package com.hc.sss.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hc.sss.common.ResultMap;
import com.hc.sss.mapper.ConservatorMapper;
import com.hc.sss.pojo.Conservator;
import com.hc.sss.service.ConservatorService;

/**
 * conservator[管理员表]service
 *
 */
@Service
public class ConservatorServiceImpl implements ConservatorService {

	@Autowired
	ConservatorMapper conservatorMapper;
	
	//修改管理员
	public int updateConservator(Conservator conservator) {
		return conservatorMapper.updateConservator(conservator);
	}
	
	//管理员登录
	public Conservator conservatorLogin(Conservator conservator) {
		return conservatorMapper.conservatorLogin(conservator);
	}

	//查询所有管理员分页
	public ResultMap<Conservator> findConservatorList(Map<String, Object> paramMap) {
		ResultMap<Conservator> resultMap = new ResultMap<Conservator>();
		Integer page = 1;
		Integer limit = 5;
		if (paramMap.get("page") != null && !"".equals(paramMap.get("page"))) {
			page = Integer.valueOf(paramMap.get("page").toString());
		}
		if (paramMap.get("limit") != null && !"".equals(paramMap.get("limit"))) {
			limit = Integer.valueOf(paramMap.get("limit").toString());
		}
		PageHelper.startPage(page, limit);
		List<Conservator> list = conservatorMapper.findConservatorList(paramMap);
		PageInfo<Conservator> info = new PageInfo<>(list);
		resultMap.setData(list);
		resultMap.setCount((int)info.getTotal());
		return resultMap;
	}

}
